package com.qf.controller;

import com.qf.pojo.RolePerm;
import com.qf.pojo.User;
import com.qf.service.RolePermService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@RestController
public class RolePermController {
    @Resource
    RolePermService rolePermService;

    @RequestMapping("/findAllRolePerm")
    public List<RolePerm> findAllRolePerm(){

        return rolePermService.findAll();
    }
    @RequestMapping("/findRolePermByid/{rpid}")
    public RolePerm findRolePermByid(@PathVariable("rpid")Integer rpid){
        return rolePermService.findRolePermByid(rpid);
    }

    @RequestMapping(value = "/addRolePerm",method = RequestMethod.POST)
    public int addRolePerm(@RequestBody RolePerm rolePerm){
        int add = rolePermService.add(rolePerm);
        if (add>0){
            return 1;
        }else {
            return 0;
        }
    }
    @RequestMapping(value = "/updateRolePerm",method = RequestMethod.POST)
    public int updateRolePerm(@RequestBody RolePerm rolePerm){
        System.out.println(rolePerm);
        int update = rolePermService.update(rolePerm);
        if (update>0){
            return 1;
        }else {
            return 0;
        }
    }

    @RequestMapping("/deleteRolePerm/{rpid}")
    public int deleteRolePerm(@PathVariable("rpid")int rpid) {
        int delete = rolePermService.delete(rpid);
        if (delete>0){
            return 1;
        }else {
            return 0;
        }
    }
}
